/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-08-22 16:44:50
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-08-22 17:11:01
 * @FilePath: /vue3-uniapp/src/mock/common.ts
 */
import type { MyInfoDetail, MyAreaEsListItem } from '@/typings/api/my';

export const readDictType = (
    dictName: string,
    param?: unknown
): Promise<MockResponse<HttpResult<DictType[]>>> => {
    switch (dictName) {
        case 'orderSourceType':
            return Promise.resolve({
                data: {
                    data: [
                        { key: 1, value: '网格发现' },
                        { key: 2, value: '12345热线' },
                        { key: 3, value: '社会治理平台' },
                        { key: 5, value: '海城原网格渠道' },
                        { key: 7, value: '12345小程序' },
                        { key: 8, value: '游北海' },
                        { key: 9, value: '上级交办' },
                        { key: 10, value: '自治区12345' },
                        { key: 11, value: '解忧超市' },
                        { key: 12, value: 'H5' },
                        { key: 13, value: '矛调平台' }
                    ],
                    code: 0,
                    msg: '操作成功',
                    desensitized: false
                }
            });
        case 'orderStatus':
            return Promise.resolve({
                data: {
                    data: [
                        { key: 1, value: '处理中' },
                        { key: 99, value: '已完成' }
                    ],
                    code: 0,
                    msg: '操作成功',
                    desensitized: false
                }
            });
        case 'appealTypeCode':
            return Promise.resolve({
                data: {
                    data: [
                        { key: 1, value: '咨询' },
                        { key: 2, value: '建议' },
                        { key: 3, value: '投诉' },
                        { key: 4, value: '举报' },
                        { key: 5, value: '求助' },
                        { key: 6, value: '表扬' }
                    ],
                    code: 0,
                    msg: '操作成功',
                    desensitized: false
                }
            });
    }
    return Promise.resolve({
        status: 404,
        data: {
            code: 404,
            msg: `mock请求/mini/api/dict/${dictName}不存在`,
            data: []
        }
    });
};

export const commonResponse = (url?: string, param?: unknown) => {
    if (url) {
        const result = url.match(/\/mini\/api\/dict\/(\S+)/);
        if (result && result.length === 2) {
            return readDictType(result[1], param);
        }
    }
};
